<?= \common\widgets\Asset::widget(['type'=>['viewer']])?>
<div class="layui-card-body" style="padding: 10px 0px">
    <div class="layui-collapse like-layui-collapse" lay-accordion=""
         style="border:1px dashed #c4c4c4">
        <div class="layui-colla-item">
            <h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示<i
                        class="layui-icon layui-colla-icon"></i></h2>
            <div class="layui-colla-content layui-show" style="background-color: #fff">
                <p>*排序规则：<span style="color: red">排序值</span>越大越靠前。创建时间最新排最前面</p>
            </div>
        </div>
    </div>
</div>
<div class="col-sm-12 search-collapse">
    <form id="role-form">
        <div class="select-list">
            <ul>
                <li><?= \common\widgets\FormInput::widget(['name'=>'select|位置','extend'=>['name'=>'where[position]','value'=>'','place'=>'所有','data'=>$this->params['positionAll']]])?></li>
                <li><?= \common\widgets\FormInput::widget(['name'=>'select|状态','extend'=>['name'=>'where[status]','value'=>'','place'=>'所有']])?></li>
                <li>
                    <?= $this->render('/iframe',['name'=>'searchbtn|搜索'])?>
                    <?= $this->render('/iframe',['name'=>'resetbtn|重置'])?>
                </li>
            </ul>
        </div>
    </form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
    <?= $this->render('/public/toolbar')?>
</div>
<div class="col-sm-12 select-table table-striped">
    <table id="bootstrap-table"></table>
</div>

<?php $this->beginBlock('script'); ?>
<script>
    var positionAll = eval(<?=json_encode($this->params['positionAll'])?>)
    $(function () {
        var options = {
            modalName: "轮播",
            sortName:'sort',
            sortOrder: "desc",
            showExport: false,
            columns: [
                {checkbox: true},
                {field: 'id', title: 'ID',  sortable: true},
                {
                    field: 'position',
                    title: '位置',
                    formatter: function (value, row, index) {
                        return positionAll[value]?positionAll[value]:'-';
                    }
                },
                {
                    field: 'img',
                    title: '图片',
                    formatter: function (value, row, index) {
                        if (value){
                            return $.table.imageView(value,null,null,'slide',row.id);
                        }
                        return '-';
                    }
                },
                // {field: 'path', align: 'center', title: '跳转路径'},
                {
                    field: "sort",
                    title: "排序",
                    sortable: true,
                },
                {
                    title: '状态',
                    field: 'status',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.view.statusTools(row,true);
                    }
                },
                {field: 'create_time', title: '创建时间', align: 'center', sortable: true},
                {field: 'update_time', title: '更新时间', align: 'center', sortable: true,visible: false},
                {field: 'note', title: '备注',visible: false},
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return '<?=$this->render("/iframe",["name"=>"formopbtn","extend"=>["type"=>["edit","delete"],"rowId"=>"row.id"]])?>';
                    }
                }
            ],
            onPostBody:function (data) {
                for (let i = 0; i < data.length; i++) {
                    if(data[i].img){
                        new Viewer(document.getElementById('pts_'+data[i].id),{navbar:false,title:false});
                    }
                }
            }
        };
        $.table.init(options);
    });
</script>
<?php $this->endBlock(); ?>

